//accepted
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
 
using namespace std;
typedef long long ll;

string s, p;

map< string , int> m;

int main(){
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	cin >> s;
	for(int i=0;i<10;i++){
		cin >> p;
		m[p]=i;
	}
	for(int i=0;i<80;i+=10){
		cout << m[s.substr(i,10)];
	}
	
	return 0;
}
